package com.ikangtai.shecare.record.bean;

import com.ikangtai.shecare.common.util.AppLog;
import com.ikangtai.shecare.common.util.DateUtil;

import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;

public class UploadVo {

	public String id;
	public String recordDate;
	public String recordEditDate;
	public UserTemperatureInfo[] userTemperatureInfos;

	public String getId() {
		return id;
	}

	public void setId(String id) {
		this.id = id;
	}

	public String getRecordDate() {
		return recordDate;
	}

	public void setRecordDate(String recordDate) {
		this.recordDate = recordDate;
	}

	public String getRecordEditDate() {
		return recordEditDate;
	}

	public void setRecordEditDate(String recordEditDate) {
		this.recordEditDate = recordEditDate;
	}

	public UserTemperatureInfo[] getUserTemperatureInfos() {
		return userTemperatureInfos;
	}

	public void setUserTemperatureInfos(UserTemperatureInfo[] userTemperatureInfos) {
		this.userTemperatureInfos = userTemperatureInfos;
	}

	public JSONObject getUserTemperatureInfoJson(){

		JSONObject jsonObject = new JSONObject();
		try {
			jsonObject.put("id", id);
			jsonObject.put("recordDate", recordDate);
			jsonObject.put("recordEditDate", recordEditDate);
			jsonObject.put("temperatures", getTemperJsonArray());

		} catch (JSONException e) {
			e.printStackTrace();
		}
		AppLog.i(jsonObject.toString());
		return jsonObject;
	}

	private JSONArray getTemperJsonArray() {

		JSONArray jsonTemperDatas = new JSONArray();
		JSONObject jsonObject;
		for(int i = 0; i < userTemperatureInfos.length; i++) {

				jsonObject = userTemperatureInfos[i].getUserTemperatureInfoJson();
			jsonTemperDatas.put(jsonObject);
		}
		return jsonTemperDatas;
	}


}
